package com.example.serviceorder.feign;

import com.example.product.Product;
import com.example.serviceorder.config.ProductsServiceConfig;
import com.example.serviceorder.feign.fallback.ProductFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

@FeignClient(name = "service-product", configuration = ProductsServiceConfig.class, fallback = ProductFeignClientFallback.class)
//@FeignClient(name = "service-product", configuration = ProductsServiceConfig.class)
// 指定调用哪个服务。自动就是负载均衡的。configuration可以指定使用那个特定配置，当然全局配置还是有作用的。
public interface ProductFeignClient {
    @GetMapping("/product/{orderId}")
    public List<Product> getProductsByOrderId(@PathVariable Long orderId);

    @GetMapping("/product/secure/{orderId}")
    public List<Product> getProductsSecure(@PathVariable Long orderId, @RequestHeader("X-Auth-Token") String authToken);
}
